package com.dly.blog.queue;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RDelayedQueue;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;

import java.util.concurrent.TimeUnit;

@Component
@RequiredArgsConstructor
@Slf4j
public class OverdueCodeQueue {

    private final RDelayedQueue<String> codeDelayedQueue;

    /**
     * Add order.
     */
    public void addCode(final String code, Integer timer) {
        //加入队列
        codeDelayedQueue.offer(code, timer, TimeUnit.SECONDS);
    }

}
